/*
 * 文 件    名:  OrderServiceProviderImpl.java
 * 创建日期:  2012-9-29上午10:07:58
 * 版          权:  Epro Technologies Co., Ltd. Copyright 2011-2012,  All rights reserved
 * 作          者:  hjd008
 */
package com.weipu.common.facade.impl;

import android.util.Log;

import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.apache.http.conn.ConnectTimeoutException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.google.android.gms.internal.cr;
import com.weipu.common.DXApplication;
import com.weipu.common.constants.Constant;
import com.weipu.common.constants.Constant.HttpMethod;
import com.weipu.common.constants.ServerConstant;
import com.weipu.common.facade.OrderServiceProvider;
import com.weipu.common.facade.exception.DxException;
import com.weipu.common.facade.model.CreateOrderStatus;
import com.weipu.common.facade.model.Operator;
import com.weipu.common.facade.model.OrderComplete;
import com.weipu.common.facade.model.OrderCreate;
import com.weipu.common.facade.model.OrderItemModel;
import com.weipu.common.facade.model.OrderModel;
import com.weipu.common.facade.model.OrderModel.ShipAddress;
import com.weipu.common.facade.model.OrderPayModel;
import com.weipu.common.facade.model.OrderPaypalModel;
import com.weipu.common.facade.model.OrderQueryTranscationsModel;
import com.weipu.common.facade.model.OrderStatusModel;
import com.weipu.common.facade.model.OrderhistoryModel;
import com.weipu.common.facade.model.Package;
import com.weipu.common.facade.model.Parmars;
import com.weipu.common.okhttp.OkHttpHelper;
import com.weipu.common.util.JsonFormat;
import com.weipu.common.util.Logger;
import com.weipu.common.util.NetWorkUtil;
import com.weipu.common.util.StringUtil;
import com.weipu.common.util.utils.SPUtils;

/**
 * @Description 订单服务提供者实现类
 * @version [版本号, 2012-9-29]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 * 
 * @author hjd008
 */
public class OrderServiceProviderImpl extends BaseServiceProviderImpl implements
		OrderServiceProvider {

	private static Map<String, String> mapUrl;

	private static Map<String, HttpMethod> mapMethod;

	// 初始化方法名和url键和值存放
	static {
		mapUrl = new HashMap<String, String>();
		mapUrl.put(ServerConstant.RequestMethodNameConstant.METHOD_FINDORDERS,
				Constant.FINDORDERS_URL);
		mapUrl.put(ServerConstant.RequestMethodNameConstant.METHOD_GETORDER,
				Constant.GETORDER_URL);
		mapUrl.put(ServerConstant.RequestMethodNameConstant.METHOD_CREATEORDER,
				Constant.CREATEORDER_URL);
		mapUrl.put(ServerConstant.RequestMethodNameConstant.METHOD_CANCELORDER,
				Constant.CANCELORDER_URL);
		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_SETMOBILECHECKOUT,
				Constant.SetMobileCheckOut_url);
		mapUrl.put(ServerConstant.RequestMethodNameConstant.METHOD_RESETMOBILE,
				Constant.RESETMOBILE_URL);

		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_PARTIALSETMOBILE,
				Constant.PARTIAL_SET_URL);
		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_CREATEORDERANDSETMOBILE_CHECKOUT,
				Constant.CREATE_ORDER_URL);
		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_GET_ORDER_COUNT,
				Constant.GET_ORDER_COUNT_URL);

		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_BEGINEDITORDER,
				Constant.BEGINEDITORDER_URL);
		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_ENDEDITORDER,
				Constant.ENDEDITORDER_URL);
		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_CHANGESHIPPINGOPTIONS,
				Constant.CHANGESHIPPINGOPTIONS_URL);
		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_GETORDERSTATUSHISTORY,
				Constant.GETORDERSTATUSHISTORY_URL);
		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_COMPLETEORDER,
				Constant.COMPLETEORDER_URL);
		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_QUERYTRANSCATIONS,
				Constant.QUERYTRANSCATIONS_URL);
		mapUrl.put(
				ServerConstant.RequestMethodNameConstant.METHOD_GETSHIPPINGINFO,
				Constant.GETSHIPPINGINFO_URL);
	}

	// 初始化方法名和httpmetod键和值存放
	static {
		mapMethod = new HashMap<String, HttpMethod>();
		mapMethod.put(
				ServerConstant.RequestMethodNameConstant.METHOD_FINDORDERS,
				HttpMethod.GET);
		mapMethod.put(ServerConstant.RequestMethodNameConstant.METHOD_GETORDER,
				HttpMethod.GET);
		mapMethod.put(
				ServerConstant.RequestMethodNameConstant.METHOD_CREATEORDER,
				HttpMethod.POST);
		mapMethod.put(
				ServerConstant.RequestMethodNameConstant.METHOD_CANCELORDER,
				HttpMethod.PUT);
		mapMethod
				.put(ServerConstant.RequestMethodNameConstant.METHOD_SETMOBILECHECKOUT,
						HttpMethod.POST);
		mapMethod.put(
				ServerConstant.RequestMethodNameConstant.METHOD_BEGINEDITORDER,
				HttpMethod.POST);
		mapMethod.put(
				ServerConstant.RequestMethodNameConstant.METHOD_ENDEDITORDER,
				HttpMethod.POST);
		mapMethod
				.put(ServerConstant.RequestMethodNameConstant.METHOD_CHANGESHIPPINGOPTIONS,
						HttpMethod.POST);
		mapMethod
				.put(ServerConstant.RequestMethodNameConstant.METHOD_GETORDERSTATUSHISTORY,
						HttpMethod.GET);
		mapMethod.put(
				ServerConstant.RequestMethodNameConstant.METHOD_COMPLETEORDER,
				HttpMethod.PUT);
		mapMethod
				.put(ServerConstant.RequestMethodNameConstant.METHOD_QUERYTRANSCATIONS,
						HttpMethod.GET);
		mapMethod
				.put(ServerConstant.RequestMethodNameConstant.METHOD_CREATEORDERANDSETMOBILE_CHECKOUT,
						HttpMethod.POST);
		mapMethod
				.put(ServerConstant.RequestMethodNameConstant.METHOD_GET_ORDER_COUNT,
						HttpMethod.POST);
		mapMethod.put(
				ServerConstant.RequestMethodNameConstant.METHOD_RESETMOBILE,
				HttpMethod.POST);
		mapMethod
				.put(ServerConstant.RequestMethodNameConstant.METHOD_PARTIALSETMOBILE,
						HttpMethod.POST);
		mapMethod
				.put(ServerConstant.RequestMethodNameConstant.METHOD_GETSHIPPINGINFO,
						HttpMethod.POST);
	}

	/**
	 * 
	 * 调用服务端接口put和post的封装方法
	 * 
	 * @param methodName
	 * @param object
	 * @return 调用的接口的方法名，map存放的参数
	 * @return String [返回类型说明]
	 * @exception throws [违例类型] [违例说明]
	 * @see [类、类#方法、类#成员]
	 */
	JSONObject postOrPutWebInterface(String methodName, Object object)
			throws DxException {
		String result = null;
		JSONObject json = null;
		try {
			// oldTime = System.currentTimeMillis();
			// ResponseEntity<String> response = restTemplate.exchange(
			// mapUrl.get(methodName), mapMethod.get(methodName),
			// requestEntity, String.class);
			OkHttpHelper okHttpHelper = OkHttpHelper.getOkHttpHelperInstance();
			if (HttpMethod.PUT.equals(mapMethod.get(methodName))) {
				result = okHttpHelper.syncPutRequest(mapUrl.get(methodName),
						object, null);
			} else {
				result = okHttpHelper.syncPostRequest(mapUrl.get(methodName),
						object, null);
			}

			json = returnResult(result);
		} catch (IOException e) {
			Logger.e(e.getMessage(), e);
			// 链接超时
			if (e.getCause() instanceof SocketTimeoutException
					|| e.getCause() instanceof ConnectTimeoutException) {
				throw new DxException(
						ServerConstant.ReturnCode.VALIDATOR_CONNECT_TIMEOUT);
			} else if (e.getCause() instanceof UnknownHostException) {
				throw new DxException(
						ServerConstant.ReturnCode.CLIENT_NET_UN_AVAILABLE);
			} else {
				if (!NetWorkUtil.isNetworkAvailable(DXApplication.getContext())) {
					throw new DxException(
							ServerConstant.ReturnCode.CLIENT_NET_UN_AVAILABLE);
				} else {
					throw new DxException(
							ServerConstant.ReturnCode.VALIDATOR_UNKONW_ERROR);
				}
			}
		}
		return json;
	}

	@Override
	public String setMobileCheckOut(OrderPaypalModel orderPayPalModel)
			throws DxException {
		String paypalUrl = null;
		JSONObject jsonObject = postOrPutWebInterface(
				ServerConstant.RequestMethodNameConstant.METHOD_SETMOBILECHECKOUT,
				orderPayPalModel);
		Logger.d("---", "--" + jsonObject.toString());
		JSONObject jsonData = jsonObject.optJSONObject(Constant.JSON_DATA);
		paypalUrl = jsonData
				.optString(ServerConstant.Parameter.PARAMETER_NAME_URL);
		if (jsonData.isNull(ServerConstant.Parameter.PARAMETER_NAME_URL)) {

			return null;
		}

		return paypalUrl;
	}

	/*
	 * 获取所有订单列表
	 * 
	 * @param customerId
	 * 
	 * @param orderdatefrom
	 * 
	 * @param pageIndex
	 * 
	 * @param pageSize
	 * 
	 * @return
	 * 
	 * @see com.weipu.common.facade.OrderServiceProvider#findOrder(int,
	 * java.lang.String, int, int)
	 */
	@Override
	public ArrayList<OrderItemModel> findOrder(String customerId,
			String orderDisplayType, String orderdatefrom, int pageIndex,
			int pageSize, String token) throws DxException {
		ArrayList<OrderItemModel> orderitem = new ArrayList<OrderItemModel>();
		JSONObject data = requestHttpGetData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_FINDORDERS)
						+ "?CustomerID="
						+ customerId
						+ "&Token="
						+ token
						+ "&orderDisplayType="
						+ orderDisplayType
						+ "&orderdatefrom="
						+ orderdatefrom
						+ "&pageIndex="
						+ pageIndex + "&pageSize=" + pageSize, null);
		JSONArray js = data.optJSONArray(Constant.JSON_RESULTSET);
		for (int i = 0; i < js.length(); i++) {
			try {
				orderitem
						.add(OrderItemModel.json2orderitem(js.optJSONObject(i)));
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		return orderitem;
	}

	/*
	 * 获得某一订单详情
	 * 
	 * @param orderNumber
	 * 
	 * @return
	 * 
	 * @see
	 * com.weipu.common.facade.OrderServiceProvider#getOrder(java.lang.String)
	 */
	@Override
	public OrderModel getOrder(String orderNumber, String token, long customerID)
			throws DxException

	{
		JSONObject js = null;
		OrderModel orderModel = new OrderModel();
		js = requestHttpGetData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_GETORDER)
						+ orderNumber
						+ "&Token="
						+ token
						+ "&CustomerID="
						+ customerID);

		OrderModel model;
		try {
			model = orderModel.json2model(js);
		} catch (JSONException e) {
			throw new DxException(e.getMessage());
		}
		return model;
	}

	/*
	 * 取消订单
	 * 
	 * @param OrderNumber
	 * 
	 * @param AutoEndEditOrder
	 * 
	 * @param OrderMemoAudienceType
	 * 
	 * @param Notes
	 * 
	 * @param Reason
	 * 
	 * @return
	 * 
	 * @see
	 * com.weipu.common.facade.OrderServiceProvider#cancelOrder(java.lang.String
	 * , boolean, java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public boolean cancelOrder(String OrderNumber, boolean IsRefund,
			String otherReason, String RefundMethod, String Reason,
			String RequestUserName, String token, long customerID)
			throws DxException {
		OrderCreate create = new OrderCreate();
		create.setOrderNumber(OrderNumber);
		create.setIsRefund(IsRefund);
		create.setOtherReason(otherReason);
		create.setRefundMethod(RefundMethod);
		create.setReason(Reason);
		create.setRequestUserName(RequestUserName);
		create.setCustomerID(customerID + "");
		create.setToken(token);
		JSONObject data = requestHttpPutData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_CANCELORDER),
				create);
		return data.optBoolean("CancelOrderSuccess", false);
	}

	/*
	 * 加锁
	 * 
	 * @param orderNumber
	 * 
	 * @param Notes
	 * 
	 * @param RquestUserName
	 * 
	 * @return
	 * 
	 * @throws DxException
	 * 
	 * @see
	 * com.weipu.common.facade.OrderServiceProvider#beginEditOrder(java.lang
	 * .String, java.lang.String, java.lang.String)
	 */
	@Override
	public String beginEditOrder(String orderNumber, String Notes,
			String RquestUserName, String token, long customerID)
			throws DxException {
		OrderCreate create = new OrderCreate();
		create.setOrderNumber(orderNumber);
		create.setNotes(Notes);
		create.setRquestUserName(RquestUserName);
		create.setCustomerID(customerID + "");
		create.setToken(token);

		// 此处需作修改
		Logger.i("beginEditOrder", "star");
		JSONObject result = requestHttpPostAll(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_BEGINEDITORDER),
				create);
		Logger.i("beginEditOrder", "end");
		return result.optString(Constant.JSON_STATUS);
	}

	/*
	 * @param 解锁
	 * 
	 * @param Notes
	 * 
	 * @param RquestUserName
	 * 
	 * @return
	 * 
	 * @throws DxException
	 * 
	 * @see
	 * com.weipu.common.facade.OrderServiceProvider#EditionOrder(java.lang.String
	 * , java.lang.String, java.lang.String)
	 */
	@Override
	public String EditionOrder(String orderNumber, String Notes,
			String RquestUserName) throws DxException {
		OrderCreate create = new OrderCreate();
		create.setOrderNumber(orderNumber);
		create.setNotes(Notes);
		create.setRquestUserName(RquestUserName);
		// 此处需作修改
		Logger.i("EditionOrder", "star");
		JSONObject result = requestHttpPostAll(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_ENDEDITORDER),
				create);
		Logger.i("EditionOrder", "end");
		return result.optString(Constant.JSON_STATUS);
	}

	/*
	 * 修改收获地址
	 * 
	 * @param CustomerIP
	 * 
	 * @param OrderNumber
	 * 
	 * @param shippingAddress
	 * 
	 * @param ShippingMethod
	 * 
	 * @return
	 * 
	 * @throws DxException
	 * 
	 * @see
	 * com.weipu.common.facade.OrderServiceProvider#ChangeShippingOptions(java
	 * .lang.String, java.lang.String,
	 * com.weipu.common.facade.model.ShippingAddress, java.lang.String)
	 */
	@Override
	public String ChangeShippingOptions(String CustomerIP, String OrderNumber,
			ShipAddress shippingAddress, String ShippingMethod)
			throws DxException {
		OrderCreate create = new OrderCreate();
		create.setCustomerIP(CustomerIP);
		create.setOrderNumber(OrderNumber);
		create.setShippingAddress(shippingAddress);
		create.setShippingMethod(ShippingMethod);
		Logger.i("ChangeShippingOptions", "star");
		JSONObject result = requestHttpPostAll(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_CHANGESHIPPINGOPTIONS),
				create);
		Logger.i("ChangeShippingOptions", "end");
		return result.optString(Constant.JSON_STATUS);
	}

	/*
	 * 获取订单历史状态
	 * 
	 * @param OrderNumber
	 * 
	 * @return
	 * 
	 * @throws DxException
	 * 
	 * @see
	 * com.weipu.common.facade.OrderServiceProvider#GetOrderStatusHistory(java
	 * .lang.String)
	 */
	@Override
	public ArrayList<OrderhistoryModel> GetOrderStatusHistory(
			String OrderNumber, String token, long customerID)
			throws DxException {
		String result = null;
		ArrayList<OrderhistoryModel> orderHistoryModel = new ArrayList<OrderhistoryModel>();

		JSONObject data = requestHttpGetData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_GETORDERSTATUSHISTORY)
						+ OrderNumber
						+ "&Token="
						+ token
						+ "&CustomerID="
						+ customerID);
		JSONArray StatusHistorys = data
				.optJSONArray(Constant.JSON_ORDERSTATUSHISTORYS);
		if (null != StatusHistorys) {
			for (int i = 0; i < StatusHistorys.length(); i++) {
				try {
					orderHistoryModel.add(OrderhistoryModel
							.jsonArray2Order(StatusHistorys.getJSONObject(i)));
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

		return orderHistoryModel;
	}

	/*
	 * 收到货后完成订单
	 * 
	 * @param OrderNumber
	 * 
	 * @param AutoEndEditOrder
	 * 
	 * @param OrderMemoAudienceType
	 * 
	 * @param Notes
	 * 
	 * @param Reason
	 * 
	 * @return
	 * 
	 * @see
	 * com.weipu.common.facade.OrderServiceProvider#CompleteOrder(java.lang.
	 * String, boolean, java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public String CompleteOrder(String OrderNumber, Operator Operator,
			String RequestUserName, String token, long customerID)
			throws DxException {
		OrderComplete orderComplete = new OrderComplete();
		orderComplete.setOrderNumber(OrderNumber);
		orderComplete.setRequestUserName(RequestUserName);
		orderComplete.setOperator(Operator);
		orderComplete.setCustomerID(customerID);
		orderComplete.setToken(token);
		Logger.i("CompleteOrder", "star");
		JSONObject data = requestHttpPutData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_COMPLETEORDER),
				orderComplete);
		Logger.i("CompleteOrder", "end");
		return data.optString(Constant.JSON_FULFILLMENTSTATUS);
	}

	/*
	 * 获取支付状态
	 * 
	 * @param BeginTime
	 * 
	 * @param CurrentPage
	 * 
	 * @param EndTime
	 * 
	 * @param OrderNumber
	 * 
	 * @param PageSize
	 * 
	 * @param UserID
	 * 
	 * @return
	 * 
	 * @see
	 * com.weipu.common.facade.OrderServiceProvider#QueryTranscations(java.lang
	 * .String, int, java.lang.String, java.lang.String, int, java.lang.String)
	 */
	@Override
	public OrderQueryTranscationsModel QueryTranscations(String BeginTime,
			int CurrentPage, String EndTime, String OrderNumber, int PageSize,
			String CustomerId) throws DxException {
		JSONObject date = requestHttpGetData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_QUERYTRANSCATIONS)
						+ "?OrderNumber="
						+ OrderNumber
						+ "&UserID="
						+ CustomerId
						+ "&BeginTime="
						+ BeginTime
						+ "&EndTime="
						+ EndTime
						+ "&CurrentPage="
						+ CurrentPage
						+ "&PageSize=" + PageSize);
		JSONObject resultSet = date.optJSONObject(Constant.JSON_RESULTSET);
		return OrderQueryTranscationsModel
				.json2orderquery(Constant.JSON_RESULTSET);
	}

	@Override
	public String createOrderAndSetMobile(OrderPaypalModel orderPayPalModel)
			throws DxException {
		String paypalUrl = null;
		String orderNumber = null;
		JSONObject jsonData = requestHttpPostData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_CREATEORDERANDSETMOBILE_CHECKOUT),
				orderPayPalModel);
		paypalUrl = jsonData
				.optString(ServerConstant.Parameter.PARAMETER_NAME_URL);
		// --新增获取订单号
		orderNumber = jsonData.optString("OrderNumber");
		if (jsonData.isNull(ServerConstant.Parameter.PARAMETER_NAME_URL)) {

			return null;
		}

		return paypalUrl + "##" + orderNumber;
	}

	@Override
	public OrderStatusModel getOrderCount(long customerId, String token)
			throws DxException {
		Parmars parmars = new Parmars();
		parmars.setCustomerID(customerId);
		parmars.setToken(token);
		JSONObject jsonData = requestHttpPostData(
				ServerConstant.RequestMethodNameConstant.METHOD_GET_ORDER_COUNT,
				parmars);
		if (null != jsonData) {
			return OrderStatusModel.jsonObject(jsonData);
		}
		return null;
	}

	@Override
	public String ReSetMobile(OrderPaypalModel orderPayPalModel)
			throws DxException {
		String paypalUrl = null;

		JSONObject jsonData = requestHttpPostData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_RESETMOBILE),
				orderPayPalModel);
		paypalUrl = jsonData
				.optString(ServerConstant.Parameter.PARAMETER_NAME_URL);
		if (jsonData.isNull(ServerConstant.Parameter.PARAMETER_NAME_URL)) {

			return null;
		}

		return paypalUrl;
	}

	@Override
	public String PartialSetMobile(OrderPaypalModel orderPayPalModel)
			throws DxException {
		String paypalUrl = null;
		JSONObject jsonData = requestHttpPostData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_PARTIALSETMOBILE),
				orderPayPalModel);
		paypalUrl = jsonData
				.optString(ServerConstant.Parameter.PARAMETER_NAME_URL);
		if (jsonData.isNull(ServerConstant.Parameter.PARAMETER_NAME_URL)) {

			return null;
		}

		return paypalUrl;
	}

	@Override
	public ArrayList<Package> GetShippingInfo(String orderNumber,
			ArrayList<Package> packages, String token, long customerID)
			throws DxException {
		// 2017/6/28 为了测试方便，这里Order Number写死了
//		orderNumber = "161011001036346890";

		Parmars param = new Parmars();
		param.setOrderNumber(orderNumber);
		param.setPackages(packages);
		param.setToken(token);
		param.setCustomerID(customerID);
		ArrayList<Package> packList = new ArrayList<Package>();
		JSONObject jsonData = requestHttpPostData(
				mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_GETSHIPPINGINFO),
				param);
		if (jsonData != null) {
			JSONArray jsonArray = jsonData
					.optJSONArray(ServerConstant.Package.PACKAGES);

			//新增字段 currencyCodeStr
			String currencyCodeStr = jsonData.optString("CurrencyCodeStr");
			StringUtil.saveConfig("CurrencyCodeStr",currencyCodeStr);

			if (jsonArray != null && jsonArray.length() > 0) {
				for (int i = 0; i < jsonArray.length(); i++) {
					Package pack = new Package();
					pack = Package.json2Object(jsonArray.optJSONObject(i));
					if (pack != null) {
						packList.add(pack);
					}
				}
			}
		}
		return packList;
	}

	@Override
	public CreateOrderStatus createOrder(OrderPayModel orderPayModel)
			throws DxException {
		JSONObject jsonData = requestHttpPostData(mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_CREATEORDER), orderPayModel);
		if (null != jsonData) {
			return CreateOrderStatus.jsonCreateOrderStatusModel(jsonData);
		}

		return null;
	}
}
